﻿using Fee.FileAttachs;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Fee.Mapping.FileAttachs
{
    public class ConstructionTaskFileAttachMapping : IEntityTypeConfiguration<ConstructionTaskFileAttach>
    {
        public void Configure(EntityTypeBuilder<ConstructionTaskFileAttach> modelBuilder)
        {
            modelBuilder
                .HasKey(t => new { t.FileId, t.TaskId });
            modelBuilder.HasOne(f => f.File).WithMany().HasForeignKey(f => f.FileId);

            modelBuilder
                .HasOne(pt => pt.Task)
                .WithMany(t => t.Attaches)
                .HasForeignKey(pt => pt.TaskId);
            modelBuilder.ToTable("fee_constructionTaskFileAttach");
        }
    }
}